package com.arturjaneczko.view.impl.clipboard._component;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import com.arturjaneczko.model.impl.EClipboardDataType;
import com.arturjaneczko.services.impl.ClipboardDataTypeConverter;

@SuppressWarnings("serial")
public class ClipboardObjectIconView extends JPanel {

	private JLabel label;

	public ClipboardObjectIconView() {
		super();
		label = new JLabel();
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setOpaque(true);
		label.setBackground(Color.NOTE.getColor());
		label.setForeground(Color.TEXT.getColor());
		label.setPreferredSize(new Dimension(50, 20));
		label.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				System.err.println("pressed");
			}
		});

		FlowLayout fl = (FlowLayout) this.getLayout();
		fl.setHgap(0);
		fl.setVgap(0);
		this.setLayout(fl);
		this.add(label);
	}

	public void update(EClipboardDataType clipboardDataType,
			java.awt.Color color) {
		label.setIcon(ClipboardDataTypeConverter.convertToIcon(
				clipboardDataType).getSystemIcon(
				clipboardDataType.getShortcut()));
		label.setBackground(color);
	}

}
